package com.lztx.shared.shared.util.image;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.bumptech.glide.request.RequestOptions;
import com.lztx.shared.R;
import com.lztx.shared.shared.util.glide.GlideApp;
import com.lztx.shared.shared.util.glide.GlideRequest;

/**
 * @name HGQBase
 * @class name：com.lztx.shared.shared.util.image
 * @describe describe
 * @anthor XINDZ
 * @time 2018/5/10 15:06
 * @change
 * @chang time
 * @class describe
 */
public class ImageUtils {
    /**
     * 占位符 - 默认
     */
    private static final int TAG_PLACEHOLDERS_DEFAULT = 1000;
    /**
     * 占位符 - 样式1
     */
    private static final int TAG_PLACEHOLDERS_ONE = 1001;
    /**
     *
     */
    private static volatile ImageUtils imageUtils;

    private ImageUtils() {
    }

    public static ImageUtils getInstance() {
        if (imageUtils == null) {
            synchronized (ImageUtils.class) {
                if (imageUtils == null) {
                    imageUtils = new ImageUtils();
                }
            }
        }
        return imageUtils;
    }

    @SuppressLint("CheckResult")
    public void getDefaultOptions() {
        RequestOptions options = new RequestOptions();
        options.error(R.drawable.ic_error);
        options.placeholder(R.drawable.ic_placeholder);
        options.fallback(R.drawable.ic_empty);

    }

    /**
     * 设置占位符
     *
     * @param options RequestOptions
     * @param TAG_PLACEHOLDERS 占位符样式
     * @return RequestOptions
     */
    private RequestOptions setPlaceholders(RequestOptions options, int TAG_PLACEHOLDERS) {
        switch (TAG_PLACEHOLDERS) {
            case TAG_PLACEHOLDERS_DEFAULT:
                break;
            case TAG_PLACEHOLDERS_ONE:
                break;

        }

        return options;
    }

    private void defaultLoad(Activity activity, Object imgUrl, ImageView imageView) {
//        GlideApp.with(activity).load(imgUrl).into(imageView);
        GlideRequest<Drawable> load = GlideApp.with(activity).load(imgUrl);

    }
}
